<template>
    <div :id="props.BiaoId" class="w-100 h-100">
    </div>
</template>
<script setup lang='ts'>
// import option from '@/assets/element-plus/es/components/select/src/option.mjs';
import * as echarts from 'echarts'
import { onMounted, ref } from 'vue'
type EChartsOption = echarts.EChartsOption;

const props = defineProps({
    BiaoId: {
        type: String,
        default: "echatrsid"
    },
    optionData:{
        type:Array,
        default: ()=>{[]}
    }


})
let myChart:any=null

onMounted(async () => {
    
 myChart = echarts.init(document.getElementById(props.BiaoId) as HTMLElement);
let option = {
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow'
    }
  },
  legend:{
    show:true
  },
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  xAxis: [
    {
      type: 'category',
      data: ['土样(原状)', '土样(扰动)', '水样', '岩样',],
      axisTick: {
        alignWithLabel: true
      }
    }
  ],
  yAxis: [
    {
      type: 'value'
    }
  ],
  series: [
    {
      name: '取样/个',
      type: 'bar',
      barWidth: '60%',
      data: [10, 52, 200, 334, ]
    }
  ]
};
myChart.setOption(option);

window.onresize = function () {//自适应大小
        myChart.resize();
    };
})
onBeforeUnmount(() => {
  // 销毁 ECharts 实例
  if (myChart) {
    myChart.dispose();
  }
});
</script>
<style lang="scss">
</style>